﻿/*
* SkillBuilder.cpp
*
* 技能创建器
*
* create date: 2014.4.21
* create by: leo
*
*/

#include "SkillBuilder.h"

#include "EmptySkill.h"
#include "Waiting.h"
#include "Walking.h"
#include "BeAttacked.h"
#include "Dying.h"
#include "Victory.h"
#include "CommonAttack.h"

USING_NS_CC;

typedef CBaseSkill* (*SkillCreater)(CBaseSkill::Param&);

typedef struct SkillDefines
{
	int type;
	SkillCreater creater;
} SkillDefines;

SkillDefines AllSkills[] = {
	{CBaseSkill::WAITING, CWaiting::create},
	{CBaseSkill::WALKING, CWalking::create},
	{CBaseSkill::BEATTACKED, CBeAttacked::create},
	{CBaseSkill::DYING, CDying::create},
	{CBaseSkill::VICTORY, CVictory::create},
	{CBaseSkill::COMMON_ATTACK, CCommonAttack::create},
	{CBaseSkill::AUTO_SKILL_1, CCommonAttack::create},
//	{CBaseSkill::EMPTY_SKILL, CEmptySkill::create},
};

CSkillBuilder& CSkillBuilder::getInstance()
{
	static CSkillBuilder instance;
	return instance;
}

CBaseSkill* CSkillBuilder::createSkill(int skillType, CBaseSkill::Param& param)
{
	CBaseSkill* skill = NULL;

	switch (skillType) {
	case CBaseSkill::EMPTY_SKILL:
		skill = CEmptySkill::create(param);
		break;
	default:
		skill = (AllSkills[skillType].creater)(param);
		break;
	}

	return skill;
}

CSkillBuilder::CSkillBuilder()
{
//	mSkillTemplates.setObject()
}

CSkillBuilder::~CSkillBuilder()
{}
